package com.artPreter.controller;


import com.artPreter.pojo.ArtVideo;
import com.artPreter.pojo.Result;
import com.artPreter.service.IArtVideoService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 视频内容表 前端控制器
 * </p>
 *
 * @author jarvis
 * @since 2024-12-24
 */
@RestController
@RequestMapping("/artVideo")
public class ArtVideoController {

    @Autowired
    private IArtVideoService artVideoService;

    /**
     * 视频分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPage")
    public Result getPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody ArtVideo artVideo) {
        IPage<ArtVideo> artVideoIPage = artVideoService.getPage(currentPage, size, artVideo);
        return Result.success(artVideoIPage);
    }

    /**
     *  添加视频
     * @param artVideo
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody ArtVideo artVideo) {
        artVideoService.add(artVideo);
        return Result.success();
    }

    /**
     *  修改视频
     * @param
     * @return
     */
    @PostMapping("/edit")
    public Result edit(@RequestBody ArtVideo artVideo) {
        artVideoService.edit(artVideo);
        return Result.success();
    }

    /**
     * 删除视频
     * @param
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody ArtVideo artVideo){
        artVideoService.delete(artVideo);
        return Result.success();
    }

    /**
     * 获取视频列表
     * @param
     * @return
     */
    @PostMapping("/getList")
    public Result getList(@RequestBody ArtVideo artVideo){
        List<ArtVideo> result = artVideoService.getList(artVideo);
        return Result.success(result);
    }

}
